/*
 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace ark::ecmascript::intrinsics {

// Autogenerated file -- DO NOT EDIT!

% Runtime::intrinsics.select(&:has_impl?).uniq { |i| i.impl }.each do |intrinsic|
%   funcname = intrinsic.impl.rpartition('::').last
%   stackrange = intrinsic.signature.respond_to?(:stackrange) && intrinsic.signature.stackrange
%   full_args = intrinsic.signature.args + (stackrange ? ['ptr'] : [])
%   params = full_args.map { |t| get_effective_type(t) }.flatten
%   params = params.each_with_index.map {|cpp_type, index| cpp_type + " " + "arg#{index}" }
%   ret_type = get_ret_effective_type(intrinsic.signature.ret)
%   use_thread = !intrinsic.respond_to?(:use_thread) || intrinsic.use_thread
%   nargs = full_args.size
%   arg_list = (0...nargs).map { |i| "arg#{i}" }
%   arg_list.insert(0, 'GetJSThread()') if use_thread
%   arg_list = arg_list.join(", ")
extern "C" <%= ret_type %> <%= funcname %>Slow(<%= params.join(", ") %>) {
%   if ret_type == 'void'
    <%= intrinsic.impl %>(<%= arg_list %>);
%   else
    return <%= intrinsic.impl %>(<%= arg_list %>);
%   end
}

%   next if !use_thread
<%= ret_type %> <%= funcname %>(<%= params.join(", ") %>) {
%   if ret_type == 'void'
    <%= intrinsic.impl %>(<%= arg_list %>);
%   else
    return <%= intrinsic.impl %>(<%= arg_list %>);
%   end
}

% end

}  // namespace ark::ecmascript::intrinsics
